<?php

	$db_host = 'localhost';
	 $db_user = 'function';
	 $db_pwd = 'w9ak4X1l0Y';

	 $database = 'function_a5110060';

	 $table = 'Function_Hall';

	$con = mysql_connect($db_host, $db_user, $db_pwd);
	if (!$con)
	die("Can't connect to database");
	mysql_select_db($database,$con);

	$subLocationId = $_REQUEST['sub_location_dd'];
	$locationId = $_REQUEST['location_dd'];
	$areaId = $_REQUEST['area_dd'];
	$hallName = $_REQUEST['hallName'];
	$address = $_REQUEST['address'];
	$accomodation = $_REQUEST['accomodation'];
	$rooms = $_REQUEST['rooms'];
	$specification = $_REQUEST['specification'];
	
	//For Uploading the Image 
	$target_path = '../../images/';
	$target_path = $target_path . basename( $_FILES['thumbnailimg']['name']);

	$thumbnailimg_target_path = $target_path;
	//for uploading
	if(move_uploaded_file($_FILES['thumbnailimg']['tmp_name'], $target_path)) {
    echo "The file ThumbnailImage ".  basename( $_FILES['thumbnailimg']['name']).
    " has been uploaded";
	} else{
		echo "There was an error uploading the Thumbnail file, please try again!";
	}

	$target_path = '../../images/';
	$target_path = $target_path . basename( $_FILES['largeimg']['name']);

	$largeimg_target_path = $target_path;
	
	//For the Large Image
	if(move_uploaded_file($_FILES['largeimg']['tmp_name'], $target_path)) {
    echo "The file large image".  basename( $_FILES['largeimg']['name']).
    " has been uploaded";
	} else{
		echo "There was an error uploading the Large Image file, please try again!";
	}
	//print_r($_FILES);
	
	//echo $_FILES['thumbnailimg']['tmp_name'];
	//Saving the files in the target path
	
	
	
	$currentDate = date("Y-m-d");

	//echo $subLocation." ".$masterLocationId;

	$sql="INSERT INTO {$table} (Location_id,Sub_Location_id,Area_id,Function_hall_name,Address,Dining_Accomodation,Room_Accomodation,Specification,Image_path,Large_image_path,Created_date,Modified_date) VALUES ('".$locationId."','".$subLocationId."','".$areaId."','".$hallName."','".$address."','".$accomodation."','".$rooms."','".$specification."','".$thumbnailimg_target_path."','".$largeimg_target_path."','".$currentDate."','".$currentDate."')";
	//echo("Sql :".$sql);
	$result=mysql_query($sql);
	//header("Location: ../FunctionHallDetails.php");
?> 